import { createI18n } from 'vue-i18n';
import { useAppStore } from '@/store/modules/app';

// const appStore = useAppStore();
// 本地语言包
import enLocale from './package/en';
import zhHansLocale from './package/zh-Hans';
import { i18nChangeLanguage } from '@wangeditor/editor';




const messages = {
  'zh-Hans': {
    ...zhHansLocale
  },
  en: {
    ...enLocale
  }
};

const i18n = createI18n({
  legacy: false,
  locale: localStorage.getItem("language")?.toString(),
  messages: messages,
  globalInjection: true
});

export function setLocale(language: string, values: any) {
  i18n.global.mergeLocaleMessage(language, values)
  if (language === 'zh-Hans') {
    i18n.global.locale.value = 'zh-Hans'
  } else {
    i18n.global.locale.value = 'en'
  }

}

export default i18n;
